<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>
<body>
    <div id='app'>
        <router-view></router-view>
    </div>
    <template id="listTemp">
        <div>
            <ul>
                <router-link tag="li" :to="'/detail/'+item.name+'/'+item.id" v-for="item in list">{{item.name}}</router-link>
            </ul>
        </div>
    </template>
    <script>
        const list = {
            template: `#listTemp`,
            data() {
                return {
                    list: [{
                        id: 1,
                        name: '李四'
                    },{
                        id: 2,
                        name: '王五'
                    },{
                        id: 3,
                        name: '张三'
                    },]
                }
            }
        }
        const detail = {
            template: `<div>详情组件:{{$route.params.name}}</div>`,
         
        }
    </script>
    <script>
        const login={
            template:`<div>登录组件</div>`
        }
        const register={
            template:`<div>注册组件</div>`
        }
        const router=new VueRouter({
            routes:[{
                    path: '/',
                    redirect: '/list'
                },{
                path:'/list',
                component:list
            },{
                path:'/detail/:name/:id',
                component:detail
            }]
        })


    const vm = new Vue({
        el: '#app',
        data: {
        },
        router:router
    })
    </script>
</body>
</html>